package Java_promotion_136_228.Java206_228;

import java.util.ArrayList;
import java.util.stream.Stream;

/*
如果希望对流中的元素进行过滤，使用filter（Boolean结果的Lambda）：
如果参数Lambda产生了true，则需要元素，反之则不需要
 */
public class _218 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(12);
        list.add(13);
        list.add(14);
        Stream<Integer> stream = list.stream().filter((Integer a) -> {
            boolean b = a > 13;
            return b;
        });
        Stream<Integer> stream1 = list.stream().filter(a -> {
            boolean b = a > 13;
            return b;
        });
        Stream<Integer> stream2 = list.stream().filter(a -> {
            return a > 13;
        });
        Stream<Integer> stream3 = list.stream().filter(a ->
                a > 13
        );
        System.out.println("======================");
        ArrayList<String> list1 = new ArrayList<>();
        list1.add("迪丽热巴");
        list1.add("马儿扎哈");
        list1.add("迪丽热巴");

        Stream<String> stream4 = list1.stream().filter((String str) -> {
            boolean b = str.equals("迪丽热巴");
            return b;
        });
        Stream<String> stream5 = list1.stream().filter(str -> {
            boolean b = str.equals("迪丽热巴");
            return b;
        });
        Stream<String> stream6 = list1.stream().filter(str -> {
            return str.equals("迪丽热巴");
        });
        Stream<String> stream7 = list1.stream().filter(str ->
                str.equals("迪丽热巴")
        );
    }
}
